﻿using System;
using System.Collections.Generic;
using NOSDC.Pocos;

namespace NOSDC.Areas.Admin.Models
{
    public class FinalizeEventModel
    {
        public IList<EventCheckBoxList> AttendeesCheckList { get; private set; }

        public bool IsFinalized { get; set; }

        private IList<EventAttendee> _attendees;
        private IList<FinalEventAttendee> _finalattendees;

        public IList<EventAttendee> Attendees
        {
            get { return _attendees; }
            set
            {
                _attendees = value;
                CreateCheckList(value);
            }
        }

        public IList<FinalEventAttendee> FinalAttendees
        {
            get { return _finalattendees; }
            set
            {
                _finalattendees = value;
                CreateCheckList(value);
            }
        }

        public FinalizeEventModel()
        {
            AttendeesCheckList = new List<EventCheckBoxList>();
        }

        private void CreateCheckList(IEnumerable<EventAttendee> attendees)
        {
            foreach (var s in attendees)
            {
                AttendeesCheckList.Add(new EventCheckBoxList { Checked = false, ID = s.UserID, Name = s.ToString() });
            }
        }

        private void CreateCheckList(IEnumerable<FinalEventAttendee> attendees)
        {
            foreach (var s in attendees)
            {
                AttendeesCheckList.Add(new EventCheckBoxList { Checked = true, ID = s.UserId, Name = s.ToString() });
            }
        }
    }

    public sealed class EventCheckBoxList
    {
        public Guid ID { get; set; }
        public string Name { get; set; }
        public bool Checked { get; set; }
    }
}